'Sponsor Requirement Script
Option Strict Off
imports System
imports PHSRAG.Insight21.Humans
imports PHSRAG.Insight21.BusinessObjects
imports FormsManagement = PHSRAG.Insight21.FormsManagement
imports System.Collections

module Script
   sub Main()
		
		Dim primarySponsor as System.String = questAnswer.GetAnswerValue("PrimarySponsor")
		Dim sponsorType as System.String = questAnswer.GetAnswerValue("SponsorType")
		
		if currentProcess.Type = "ANIMALPPTYPE_IR" and primarySponsor = "Y" then

			'set this sponsor as the protocol's Sponsor.
			if ( questAnswer.ExternalId <> 0 ) then 
			    theProtocol.SponsorId = questAnswer.ExternalId
			else if ( sponsorType = "DepartmentFund" ) then 
			    theProtocol.SponsorId = 3749
			end if

			theProtocol.Save( connectionString )
	end if
		
   end sub
end module